package com.wl.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/c")
public class CServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 创建session
        HttpSession session = req.getSession(true);
        session.setAttribute("author","wl");
        session.setAttribute("author","wyc");
        session.removeAttribute("author");
//        session.invalidate();

        // 得到app
        ServletContext app = this.getServletContext();
        app.setAttribute("version","v1.0");
        app.setAttribute("version","v2.0");
        app.removeAttribute("version");
    }
}
